一款自制的android手电筒软件
public void onClick(View v) {
if(statusFlag){
statusButton.setBackgroundResource(R.drawable._kai);
camera = Camera.open();
parameters = camera.getParameters();
parameters.setFlashMode(Parameters.FLASH_MODE_TORCH);//开启
camera.setParameters(parameters);
statusFlag = false;
}else{
statusButton.setBackgroundResource(R.drawable._guan);
parameters.setFlashMode(Parameters.FLASH_MODE_OFF);//关闭
camera.setParameters(parameters);
statusFlag = true;
camera.release();
}
}
评论